export default {
    mode: 'universal',
    /*
     ** Headers of the page
     */
    head: {
        title: process.env.npm_package_name || '',
        meta: [{
                charset: 'utf-8'
            },
            {
                name: 'viewport',
                content: 'width=device-width, initial-scale=1'
            },
            {
                hid: 'description',
                name: 'description',
                content: process.env.npm_package_description || ''
            }
        ],
        link: [{
            rel: 'icon',
            type: 'image/x-icon',
            href: '/favicon.ico'
        }, {
            rel: 'stylesheet',
            type: 'text/css',
            href: "/css/myindex.css"
        }],
        script: [{
            type: 'text/javascript',
            src: "/js/arrayExtend.js"
        }]
    },
    /*
     ** Customize the progress-bar color
     */
    loading: {
        color: '#fff',
        height: '5px'
    },
    /*
     ** Global CSS
     */
    css: [
        'element-ui/lib/theme-chalk/index.css'
    ],
    /*
     ** Plugins to load before mounting the App
     */
    plugins: [
        '@/plugins/element-ui',
        '@/plugins/axios',
        '@/plugins/httpapi',
    ],
    /*
     ** Nuxt.js dev-modules
     */
    buildModules: [
        // Doc: https://github.com/nuxt-community/stylelint-module
        '@nuxtjs/stylelint-module',
    ],
    /*
     ** Nuxt.js modules
     */
    modules: [
        // Doc: https://axios.nuxtjs.org/usage
        '@nuxtjs/axios', //数据请求
        '@nuxtjs/proxy', //本地代理
        '@nuxtjs/auth' //身份验证  使用请看 https://auth.nuxtjs.org/ [暂时未调通]
    ],
    /*
     ** Axios module configuration
     ** See https://axios.nuxtjs.org/options
     */
    axios: {
        proxy: true, // 表示开启代理
        prefix: '/api', // 表示给请求url加个前缀 /api
        credentials: true // 表示跨域请求时是否需要使用凭证
    },
    proxy: {
        '/api': {
            target: 'https://localhost:44312', // 目标接口域名
            changeOrigin: true, // 表示是否跨域
            "secure": false, //免证书校验  不加这个会报 UNABLE_TO_VERIFY_LEAF_SIGNATURE
            pathRewrite: {
                '^/api': '/api', // 把 /api 替换成‘’
            }
        }
    },
    /*
     ** Build configuration
     */
    build: {
        transpile: [/^element-ui/],
        /*
         ** You can extend webpack config here
         */
        extend(config, ctx) {}
    },
    // middleware: 'auth',  [暂时未调通]
    auth: { //身份验证配置  [暂时未调通]
        // Options
        strategies: { //每个端点都用于使用axios发出请求
            local: {
                endpoints: {
                    login: {
                        url: '/login/token',
                        method: 'post',
                        propertyName: 'token'
                    },
                    logout: {
                        url: '/login/logout',
                        method: 'post'
                    },
                    user: {
                        url: '/login/user',
                        method: 'get',
                        propertyName: 'user'
                    }
                },
                tokenRequired: true, //此选项可用于禁用所有令牌处理。仅对Cookie有用。（默认情况下启用）
                tokenName: 'Authorization', //在axios请求中使用的授权标头名称
                tokenType: 'Bearer', //在axios请求中使用的授权标头类型
                autoFetchUser: true, //此选项可用于禁用登录后的用户获取。当您的登录响应中已有该用户时，这将很有用。
                notLoggedInRedirectTo: '/login',
                loggedInRedirectTo: '/'
            }

            //propertyName可用于指定响应JSON的哪个字段用于值。可以false直接使用API​​响应，也可以更复杂auth.user
        }
    },
    router: {
        middleware: ['auth']
    } //,
    // generate: {
    //     fallback: true, // if you want to use '404.html'
    //     fallback: '/' // if your hosting needs a custom location
    // }

}